<?php
include("sql.php");
session_start();

if ( !isset($_POST['name'])){  echo  "<script language=\"javascript\">location.href=\"reg_user.php\"; </script>";}
session_start(); 
		if(isset($_SESSION['email'])){ echo "<script language=\"javascript\"> alert (\"already registered\");location.href=\"reg_user.php\";</script>";}

$name=$_POST['name'];
$query= "select name from login where name= '" .$name. "' ";	
	$result=mysql_query($query);

		$numrows=mysql_num_rows($result);
		if ( $numrows>0){echo "alert (\"name already registered\");<script language=\"javascript\">location.href=\"reg_user.PHP?w=2\";</script>"; die();}


if (!mysql_query($query))
  {
  die('Error: ' . mysql_error());
  }
$college=$_POST['college'];
$age=$_POST['age'];
$email=$_POST['email'];
$ph=$_POST['officeph'];
$address=$_POST['address'];
$pass=$_POST['pass1'];
$passp=md5($pass);
$query2= " insert into login values(\"$name\",\"$passp\",\"$college\",\"$age\",\"$email\",\"$ph\",\"$address\",-1,0,\"0\")";
//$result=mysql_query($query);
if (!mysql_query($query2))
  {
  die('Error: ' . mysql_error());
  }
$_SESSION['email']=$email;
$_SESSION['name']=$name;
$_SESSION['aq']=-1;

$query3="insert into usertrack values(\"$email\",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);";
if(!mysql_query($query3)){ die('Error: ' . mysql_error());}

echo  "<script language=\"javascript\">location.href=\"index.php\"; </script>";
?>
</body>

</html>
